package Phase;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;
import java.io.File;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.imageio.ImageIO;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.SpringLayout;

public class ArkanoidPanel extends JPanel {

    private JDoubleBufferedPanel boardPanel;
    private JDoubleBufferedPanel lifePanel;
    private JDoubleBufferedPanel scorePanel;
    private JDoubleBufferedPanel timePanel;
    private JPanel topBoundaryPanel;
    private JPanel leftBoundaryPanel;
    private JPanel rightBoundaryPanel;
    private JPanel downBoundaryPanel;
    private JPanel begginingPanel;

    public ArkanoidPanel() {
        begginingPanel = new JPanel();
        begginingPanel.setSize(new Dimension(465, 100));
        begginingPanel.setMaximumSize(new Dimension(465, 100));
        begginingPanel.setMinimumSize(new Dimension(465, 100));
        begginingPanel.setPreferredSize(new Dimension(465, 100));

        topBoundaryPanel = new JPanel();
        topBoundaryPanel.setSize(new Dimension(465, 18));
        topBoundaryPanel.setMaximumSize(new Dimension(465, 18));
        topBoundaryPanel.setMinimumSize(new Dimension(465, 18));
        topBoundaryPanel.setPreferredSize(new Dimension(465, 18));

        leftBoundaryPanel = new JPanel();
        leftBoundaryPanel.setSize(new Dimension(18, 449));
        leftBoundaryPanel.setMinimumSize(new Dimension(18, 449));
        leftBoundaryPanel.setMaximumSize(new Dimension(18, 449));
        leftBoundaryPanel.setPreferredSize(new Dimension(18, 449));

        rightBoundaryPanel = new JPanel();
        rightBoundaryPanel.setSize(new Dimension(18, 449));
        rightBoundaryPanel.setMinimumSize(new Dimension(18, 449));
        rightBoundaryPanel.setMaximumSize(new Dimension(18, 449));
        rightBoundaryPanel.setPreferredSize(new Dimension(18, 449));

        downBoundaryPanel = new JPanel();
        downBoundaryPanel.setSize(new Dimension(18, 449));
        downBoundaryPanel.setMinimumSize(new Dimension(18, 449));
        downBoundaryPanel.setMaximumSize(new Dimension(18, 449));
        downBoundaryPanel.setPreferredSize(new Dimension(18, 449));

        boardPanel = new JDoubleBufferedPanel();
        boardPanel.setSize(new Dimension(429, 449));
        boardPanel.setPreferredSize(new Dimension(429, 449));
        boardPanel.setMinimumSize(new Dimension(429, 449));
        boardPanel.setMaximumSize(new Dimension(429, 449));
        boardPanel.setVisible(true);

        lifePanel = new JDoubleBufferedPanel();
        lifePanel.setSize(new Dimension(100, 25));
        lifePanel.setPreferredSize(new Dimension(100, 25));
        lifePanel.setMinimumSize(new Dimension(100, 25));
        lifePanel.setMaximumSize(new Dimension(100, 25));
        lifePanel.setBackground(Color.LIGHT_GRAY);
        lifePanel.setLayout(new SpringLayout());
        lifePanel.setVisible(true);
        lifePanel.setBorder(BorderFactory.createLineBorder(Color.yellow));

        scorePanel = new JDoubleBufferedPanel();
        scorePanel.setSize(new Dimension(100, 25));
        scorePanel.setPreferredSize(new Dimension(100, 25));
        scorePanel.setMinimumSize(new Dimension(100, 25));
        scorePanel.setMaximumSize(new Dimension(100, 25));
        scorePanel.setBackground(Color.red);
        scorePanel.setVisible(true);
        scorePanel.setBorder(BorderFactory.createLineBorder(Color.BLUE));

        timePanel = new JDoubleBufferedPanel();
        timePanel.setSize(new Dimension(100, 25));
        timePanel.setPreferredSize(new Dimension(100, 25));
        timePanel.setMinimumSize(new Dimension(100, 25));
        timePanel.setMaximumSize(new Dimension(100, 25));
        timePanel.setBackground(Color.YELLOW);
        timePanel.setVisible(true);
        timePanel.setBorder(BorderFactory.createLineBorder(Color.BLACK));

        begginingPanel.add(timePanel);
        begginingPanel.add(scorePanel);
        begginingPanel.add(lifePanel);

        this.setFocusable(true);
        this.add(begginingPanel, BorderLayout.PAGE_START);
        this.add(topBoundaryPanel, BorderLayout.PAGE_START);
        this.add(leftBoundaryPanel);
        this.add(boardPanel, BorderLayout.CENTER);
        this.add(rightBoundaryPanel);
        this.add(downBoundaryPanel);
        this.setSize(new Dimension(800, 800));
        this.setVisible(true);

        /*boardPanel = new JDoubleBufferedPanel();
         boardPanel.setSize(new Dimension(400, 300));
         boardPanel.setPreferredSize(new Dimension(400, 300));
         boardPanel.setMinimumSize(new Dimension(400, 300));
         boardPanel.setMaximumSize(new Dimension(400, 300));
         boardPanel.setVisible(true);
        
         lifePanel = new JDoubleBufferedPanel();
         lifePanel.setSize(new Dimension(100, 25));
         lifePanel.setPreferredSize(new Dimension(100, 25));
         lifePanel.setMinimumSize(new Dimension(100, 25));
         lifePanel.setMaximumSize(new Dimension(100, 25));
         lifePanel.setBackground(Color.LIGHT_GRAY);
         lifePanel.setLayout(new SpringLayout());
         lifePanel.setVisible(true);
         lifePanel.setBorder(BorderFactory.createLineBorder(Color.yellow));
        
         scorePanel = new JDoubleBufferedPanel();
         scorePanel.setSize(new Dimension(100, 25));
         scorePanel.setPreferredSize(new Dimension(100, 25));
         scorePanel.setMinimumSize(new Dimension(100, 25));
         scorePanel.setMaximumSize(new Dimension(100, 25));
         scorePanel.setBackground(Color.red);
         scorePanel.setVisible(true);
         scorePanel.setBorder(BorderFactory.createLineBorder(Color.BLUE));
        
         timePanel = new JDoubleBufferedPanel();
         timePanel.setSize(new Dimension(100, 25));
         timePanel.setPreferredSize(new Dimension(100, 25));
         timePanel.setMinimumSize(new Dimension(100, 25));
         timePanel.setMaximumSize(new Dimension(100, 25));
         timePanel.setBackground(Color.YELLOW);
         timePanel.setVisible(true);
         timePanel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
        
         this.setFocusable(true);
         this.add(timePanel, BorderLayout.PAGE_START);
         this.add(scorePanel, BorderLayout.PAGE_START);
         this.add(boardPanel, BorderLayout.CENTER);
         this.add(lifePanel, BorderLayout.PAGE_END);
         this.setSize(new Dimension(800, 800));
         this.setVisible(true);*/
    }

    public JDoubleBufferedPanel getCanvas() {
        return boardPanel;
    }

    public JDoubleBufferedPanel getLifePanel() {
        return lifePanel;
    }

    public JDoubleBufferedPanel getScorePanel() {
        return scorePanel;
    }

    public JDoubleBufferedPanel getTimePanel() {
        return timePanel;
    }
}
